package rubix.controller;

import rubix.model.*;
import java.util.zip.*;
import java.util.*;
import java.io.*;
import au.com.bytecode.opencsv.CSVReader;
import java.text.SimpleDateFormat;

/**
 * This controller contains methods to facilitate the bootstrapping of data
 */
public class BootstrapController {

    private ArrayList<String[]> userData;
    private ArrayList<String[]> supplierData;
    private ArrayList<String[]> inventoryData;
    private ArrayList<String[]> poData;
    private LinkedHashMap<String, User> userList;
    private LinkedHashMap<String, Supplier> supplierList;
    private LinkedHashMap<String, Inventory> inventoryList;
    private LinkedHashMap<String, Po> poList;
    private static int poLoaded;
    private static int userLoaded;
    private static int inventoryLoaded;
    private static int supplierLoaded;
    private ArrayList<LinkedHashMap<String, Object>> allErrors;

    public BootstrapController() {
        userList = new LinkedHashMap<String, User>();
        supplierList = new LinkedHashMap<String, Supplier>();
        inventoryList = new LinkedHashMap<String, Inventory>();
        poList = new LinkedHashMap<String, Po>();
        
        poLoaded = 0;
        userLoaded = 0;
        inventoryLoaded = 0;
        supplierLoaded = 0;

        allErrors = new ArrayList<LinkedHashMap<String, Object>>();
        InventoryManager.prepareTables();
        ItemManager.prepareTables();
        PartManager.prepareTables();
        PoManager.prepareTables();
        SupplierManager.prepareTables();
        UserManager.prepareTables();
    }

    /**
     * Stores the content of student.csv into an ArrayList for validation
     */
    public void processStudentFile(ZipInputStream zipInputStream) {
        BufferedReader br = new BufferedReader(new InputStreamReader(zipInputStream));
        CSVReader reader = new CSVReader(br, ',', '"', 1);
        String[] columns;
    }
}